# -*- coding: utf-8 -*-
# @Create_time   : :
# @Author        :kumiler
# @emial         :lukunming@jtexpress.com
# @File          :.py
# @Desc          :


from datetime import timedelta
from utils.operators.cluster_for_spark_sql_operator import SparkSqlOperator
from spmi_fee_domain.dwd_slim.dwd_spmi_composite_bill_incre_dt import spmi_dwd__dwd_spmi_composite_bill_incre_dt
from spmi_fee_domain.time_sensor.time_after_06_20 import time_after_06_20

spmi_dm__dm_spmi_composite_bill_sum_dt = SparkSqlOperator(
    task_id='spmi_dm__dm_spmi_composite_bill_sum_dt',
    email=['lukunmingn@jtexpress.com','yl_bigdata@yl-scm.com'],
    master='yarn',
    name='spmi_dm__dm_spmi_composite_bill_sum_dt_{{ execution_date | date_add(1) | cst_ds }}',
    sql='spmi_fee_domain/dm/dm_spmi_composite_bill_sum_dt/execute.sql',
    pool_slots=2,
    driver_cores=2,
    driver_memory='6G',
    executor_cores=5,
    executor_memory='12G',
    num_executors=90,
    conf={'spark.dynamicAllocation.enabled'                  : 'true',
          'spark.shuffle.service.enabled'                    : 'true',
          'spark.dynamicAllocation.maxExecutors'             : 110,
          'spark.dynamicAllocation.cachedExecutorIdleTimeout': 60,
          'spark.sql.sources.partitionOverwriteMode'         : 'dynamic',
          'spark.executor.memoryOverhead'                    : '3G',
          'spark.yarn.maxAppAttempts'                        : 1,
          'spark.sql.shuffle.partitions': 1800,
          'spark.io.compression.codec': 'org.apache.spark.io.ZStdCompressionCodec'
          },
    hiveconf={'hive.exec.dynamic.partition'             : 'true',  # 动态分区
              'hive.exec.dynamic.partition.mode'        : 'nonstrict',
              'hive.exec.max.dynamic.partitions'        : 100,  # 最大分区
              'hive.exec.max.dynamic.partitions.pernode': 100,  # 最大分区
              },
    yarn_queue='pro',
    execution_timeout=timedelta(minutes=100),
    retries=0,
)

spmi_dm__dm_spmi_composite_bill_sum_dt << spmi_dwd__dwd_spmi_composite_bill_incre_dt
